Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IntRange explicitly inclusive to [min, max]. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

schmich
Copy link

@schmich schmich commented Jan 12, 2016

It's not entirely clear, but it looks like IntRange was meant to be fully inclusive to the range [min, max]. Before this change, it was exclusive to max, i.e. the range was [min, max).

This change makes IntRange fully inclusive. This also fixes a bug in StringRange that was only generating strings up to max - 1 length (instead of generating strings up to max length as per its comment).

With this fix, the max == min case is handled automatically, so no switch is required. I also had to adjust the other utility functions to take into account the inclusive max.

If IntRange was meant to be [min, max) only, feel free to reject this PR, but I'd then recommend fixing StringRange and making it clear that IntRange excludes max.

This fixes a length bug with StringRange as well where generated strings were no more than max-1 characters long (instead of being no more than max characters long as described).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant